// pages/singer/singer.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        letter: ["热门","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],
        classify: ["全部","华语男","华语女","华语组合","日韩男","日韩女","日韩组合","欧美男","欧美女","欧美组合","其他"],
        index1: 0,
        singerList: [],
        page: 1,
        index2: 0
        
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
       this.getData()
    },

    letterClick(e){
        this.setData({
            index1: e.currentTarget.dataset.index,
            singerList: [],
            page: 1
        }, () => {
            this.getData()
        })
       
    },

    // // 歌手分类
    singClass(e){
        
        this.setData({
            index2: e.currentTarget.dataset.index,
            singerList: [],
            page: 1
        }, () => {
            this.getData()
        })
        
    },

    goDetail(e){
        // console.log(e.currentTarget.dataset.id);
        wx.navigateTo({
          url: '/pages/singerDetail/singerDetail?id=' + e.currentTarget.dataset.id,
        })
    },



    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {
        
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
       
    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
       this.setData({
           page: this.data.page + 1
       },() => {
           this.getData()
       })
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },
    getData(){
        let obj = {
            category: this.data.index2,
            pn: this.data.page,
            rn: 8
        }
        this.data.index1 && (obj.prefix = this.data.letter[this.data.index1])
        wx.request({
          url: 'http://192.168.124.104:8080/artist/artistInfo',
          data: obj,
          success: res=> {
              this.setData({
                  singerList: [...this.data.singerList, ...res.data.data.artistList]
              })
          }
        })
    }
})